package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Class cls=Class.forName("reflect.Person");
        Object obj=cls.newInstance();
        Method m1=cls.getMethod("la", String.class);
        m1.invoke(obj,"屎");

        Method m2=cls.getMethod("drink", String.class, int.class);
        m2.invoke(obj,"西瓜汁",10);
    }
}
